home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / gnu / gnu_tile_forth.lha / tst / bitfields.tst next >
Text File  |  1992-05-19  |  1KB  |  61 lines

  1. .( Loading Bitfields test...) cr
  2.  
  3. #include bitfields.f83
  4.  
  5. bitfields
  6.  
  7. .( 1: Create a demo bit field definition) cr
  8.  
  9. bitfield.type STATUS-REG ( -- )
  10.   bit    ERROR ( -- pos width)
  11. 3 bits   ERROR.CODE ( -- pos width)
  12.   nibble INDEX ( -- pos width)
  13.   bit    INDIRECT ( -- pos width)
  14.   byte   OP.CODE ( -- pos width)
  15. bitfield.end
  16.  
  17.  
  18. .( 2: Print information about the fields) cr
  19.  
  20. ERROR . . cr
  21. ERROR.CODE . . cr
  22. INDEX . . cr
  23. INDIRECT . . cr
  24. OP.CODE . . cr
  25.  
  26.  
  27. .( 3: Access some data with the fields) cr
  28.  
  29. binary
  30.  
  31. 10101001000101111 ERROR drop b@ .
  32. 10101001000101111 INDIRECT drop b@ . cr
  33.  
  34. 10101001000101111 ERROR f@ .
  35. 10101001000101111 ERROR.CODE f@ .
  36. 10101001000101111 INDEX f@ .
  37. 10101001000101111 INDIRECT f@ .
  38. 10101001000101111 OP.CODE f@ . cr
  39.  
  40. 10101001000101111 ERROR <f@ .
  41. 10101001000101111 ERROR.CODE <f@ .
  42. 10101001000101111 INDEX <f@ .
  43. 10101001000101111 INDIRECT <f@ .
  44. 10101001000101111 OP.CODE <f@ . cr
  45.  
  46.  
  47. .( 4: Change bit fields in some data) cr
  48.  
  49. 0        10101001000101111 ERROR drop b!    ERROR drop b@ .
  50. 1        10101001000101111 INDIRECT drop b! INDIRECT drop b@ . cr
  51.  
  52. 0        10101001000101111 ERROR f!      ERROR f@ .
  53. 101      10101001000101111 ERROR.CODE f! ERROR.CODE f@ .
  54. 1111     10101001000101111 INDEX f!      INDEX f@ . 
  55. 1        10101001000101111 INDIRECT f!   INDIRECT f@ . 
  56. 10111111 10101001000101111 OP.CODE f!    OP.CODE f@ . cr
  57.  
  58. decimal
  59.  
  60. forth only
  61.